﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CustomerService
{
    public partial class tabNotes : System.Web.UI.UserControl
    {
        private SalesManagerEntities _context;
        private tblCustomer _customer;
        private List<tblNote> _notes;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
            }
        }

        public new void Load(SalesManagerEntities context, tblCustomer customer)
        {
            _context = context;
            _customer = customer;

            if (_customer != null)
            {
                _notes = new List<tblNote>();
                foreach (tblCustomerNote cn in _customer.CustomerNotes)
                    _notes.Add(cn.Note);
                _notes.Sort((A, B) => B.NoteDate.CompareTo(A.NoteDate));

                lstNotes.DataSource = _notes;
                lstNotes.DataBind();
            }
        }

    }
}